<?php
/**
* @package   com_zoo
* @author    YOOtheme http://www.yootheme.com
* @copyright Copyright (C) YOOtheme GmbH
* @license   http://www.gnu.org/licenses/gpl-2.0.html GNU/GPLv2 only
*/

/*
	Class: ElementEvent
		Element events.
*/
class ElementEvent {

	public static function beforeDisplay($event) {

		$item = $event->getSubject();
		$element = $event['element'];

		// element will not be rendered if $event['render'] is set to false
		// $event['render'] = false;

	}

	public static function afterDisplay($event) {

		$item = $event->getSubject();
		$element = $event['element'];

		// set $event['html'] after modifying the html
		// $html = $event['html'];
		// $event['html'] = $html;
	}

	public static function beforeSubmissionDisplay($event) {

		$item = $event->getSubject();
		$element = $event['element'];

		// element will not be rendered if $event['render'] is set to false
		// $event['render'] = false;

	}

	public static function afterSubmissionDisplay($event) {

		$item = $event->getSubject();
		$element = $event['element'];

		// set $event['html'] after modifying the html
		// $html = $event['html'];
		// $event['html'] = $html;
	}

	public static function configParams($event) {

		$element = $event->getSubject();

		if (in_array($element->getElementType(), array('checkbox', 'country', 'date', 'email', 'itemcategory', 'itemtag', 'link', 'radio', 'relatedcategories', 'relateditems', 'select', 'text'))) {
			$params = $event->getReturnValue();

			$params[] =
				'<wrapper><params group="render">
					<param name="separated_by" type="zoolist" default="Space" label="Separated by" description="CHOOSE_SEPARATOR_REPEATED_ELEMENTS">
						<option name="Space"><![CDATA[separator=[ ]]]></option>
						<option name="Comma"><![CDATA[separator=[, ]]]></option>
						<option name="Hyphen"><![CDATA[separator=[ - ]]]></option>
						<option name="Pipe"><![CDATA[separator=[ | ]]]></option>
						<option name="Break"><![CDATA[separator=[<br />]]]></option>
						<option name="Span"><![CDATA[tag=[<span>%s</span>]]]></option>
						<option name="Paragraph"><![CDATA[tag=[<p>%s</p>]]]></option>
						<option name="Div"><![CDATA[tag=[<div>%s</div>]]]></option>
						<option name="List Item"><![CDATA[tag=[<li>%s</li>]]]></option>
						<option name="Unordered List"><![CDATA[tag=[<li>%s</li>] enclosing_tag=[<ul>%s</ul>]]]></option>
						<option name="Ordered List"><![CDATA[tag=[<li>%s</li>] enclosing_tag=[<ol>%s</ol>]]]></option>
						<option name="Warp Item"><![CDATA[tag=[<article class="item">%s</article>]]]></option>
					</param>
				</params></wrapper>';

			$event->setReturnValue($params);
		}

	}

	public static function configForm($event) {

		$element = $event->getSubject();
		$form = $event['form'];

	}

	public static function configXML($event) {

		$element = $event->getSubject();
		$xml = $event['xml'];

	}

	public static function download($event) {

		$download_element = $event->getSubject();
		$check = $event['check'];
	}

	public static function afterEdit($event) {

		$element = $event->getSubject();

		// set $event['html'] after modifying the html
		// $html = $event['html'];
		// $event['html'] = $html;
	}

}